const { ccclass, property } = cc._decorator;

import s from "./AbTestMgr"
import c from "./PeripheralSystemDataMgr"
import u from "./EventMgr"
import p from "./MatchGameEventType"
import d from "./frameworkManager"
import f from "./ClientData"
import g from "./Queue"
import y from "./SdkHelper"
import m from "./EngineUtil"
import _ from "./TimeUtils"
import v from "./MatchGameViewCtrl"
import b from "./MatchGameConfig"
import C, { ObstacleAllType, ObstacleTargetName } from "./ObstacleConfig"
import T from "./MatchGameAudioMgr"
import M from "./MatchGameDataMgr"
import P from "./MatchItemCtrl"
import S from "./ObstacleCtrl"
import EngineUtil from "./EngineUtil";
var debugerGamelevel = 0;
interface PropInfo {
    skillType: SkillType;
    skillCount: number;
  }
  
export enum SkillType {
    Null = -1,
    Hammer = 2,
    Arrow = 3,
    Gun = 4,
    Shiff = 5,
}

export enum MatchGameStatus {
    BrforeGame = 1,
    DuringGame = 2,
    EndGame = 3,
    LostGame = 4,
    FinishGame = 5,
    NoElimate = 6,
}

@ccclass
class MatchGameData extends cc.Component {

    static SkillType = {
        Null: -1,
        Hammer: 2,
        Arrow: 3,
        Gun: 4,
        Shiff: 5
    }

    static MatchGameStatus = {
        BrforeGame: 1,
        DuringGame: 2,
        EndGame: 3,
        LostGame: 4,
        FinishGame: 5,
        NoElimate: 6
    }

    public isEditor = false;
    public startGuideType = 0;
    public total_step = 0;
    public video_step = 0;
    public left_step = 0;
    public finish_propCount = 0;
    public afterEndGameCash = 0;
    public curLevelCash = 0;
    public levelCoinCount = 0;
    public haveShowEndGamePage = false;
    public ad_flag = false;
    public full_ad_flag = false;
    public force_video = false;
    public allFillQueue = new g();
    public allFillArr = [];
    public lastAllFillTime = 0;
    public nextFillInterval = 500;
    public startGameTime = 0;
    public startReplaceStep = false;
    public backend_level_flag = 0;
    public duringGuide = false;
    public skipEndGameReplacement = false;
    public curFlyBoxCash = 0;
    public totaleFlyBoxCash = 0;
    public lastFlyBoxVdStartTime = 0;
    public allFlyBoxTime = 0;
    public cityConfig = null;
    public _gameInfo = null;
    public target_info = [];
    public _gameLevel = 0;
    public _profile = null;
    public levelCategory = null;
    public guideIndex = 0;
    public finishOneEliminate = false;
    public gameStatus = MatchGameData.MatchGameStatus.BrforeGame;
    public endGamePropCount = 0;
    public propInfo = [];
    public _obstacle_count_info = [];
    public _middle_square_grid = [];
    public _bottom_square_grid = [];
    public _top_square_grid = [];

    static _instance;
    static getInstance(): MatchGameData {
        MatchGameData._instance || (MatchGameData._instance = new MatchGameData());
        return MatchGameData._instance;
    };
    public getGameInfo() {
        return this._gameInfo;
    };
    public setGameInfo(e) {
        this._gameInfo = e;
    };

    public initLevelCash() {
        this.curLevelCash = 0;
    };
    public addLevelCash(e) {
        void 0 === e && (e = 1);
        this.curLevelCash += e;
    };
    public getCurLevelCash() {
        return this.curLevelCash;
    };
    public addRedBack(e?) {
        void 0 === e && (e = 1);
    };
    public addEndGameCash(e?) {
        void 0 === e && (e = 1);
        if (!this.haveShowEndGamePage) {
            this.afterEndGameCash += e;
            d.log("this.afterEndGameCash", this.afterEndGameCash);
            u.trigger(p.UPDATE_AFTER_GAME_CASH);
        }
    };
    get gameLevel(): number {
        if (debugerGamelevel) return debugerGamelevel;
        return Number(EngineUtil.localStorageGetItem("gamelevel", 1));
        // return this._gameLevel;
    }

    set gameLevel(e: number) {
        this._gameLevel = e || 1;
        EngineUtil.localStorageSetItem("gamelevel", this._gameLevel);
    }

    get profile(): any {
        return this._profile;
    }

    public setEndGameCash(e) {
        this.afterEndGameCash = e;
    };
    public initStartGameTime() {
        this.startGameTime = _.getTimeInSeconds();
        this.lastFlyBoxVdStartTime = 0;
        this.allFlyBoxTime = 0;
    };
    public onPlayFlyBoxVd() {
        this.lastFlyBoxVdStartTime = _.getTimeInSeconds();
    };
    public onFlyBoxVdFinish() {
        if (this.lastFlyBoxVdStartTime) {
            var e = _.getTimeInSeconds() - this.lastFlyBoxVdStartTime;
            this.allFlyBoxTime += e;
        }
    };
    public getGameTime() {
        var e = _.getTimeInSeconds() - this.startGameTime;
        return this.allFlyBoxTime >= e ? e : e - this.allFlyBoxTime;
    };
    public addFlyBoxCash(e) {
        this.curFlyBoxCash = e;
        this.totaleFlyBoxCash += this.curFlyBoxCash;
    };
    public getFlyBoxCash() {
        return this.totaleFlyBoxCash;
    };
    public getCurFlyBoxCash() {
        return this.curFlyBoxCash;
    };
    public setGameData(e) {
        console.log(JSON.stringify(e), 323232321111111)
        this.resetUpdateTargetCount();
        this.allFillArr = [];
        this.lastAllFillTime = 0;
        e.cash_balance;
        var t = e.game_level, a = (e.gold_balance, e.profile), o = e.props, i = e.ad_flag, r = e.full_ad_flag, n = e.backend_level_flag, s = (a.EVENT_TYPE,
            a.LEVEL_CODE), c = a.LEVEL_STEEPS, u = (a.REWARD_MONEY, a.STARTGUIDE_TYPE);
        this.backend_level_flag = n || 0;
        this.gameLevel = Number(t);
        this.total_step = c || s.totalStep;
        this.left_step = this.total_step;
        this.video_step = 0;
        this.finish_propCount = 0;
        this.startGuideType = u;
        this.guideIndex = s.guideIndex || 0;
        this.gameStatus = MatchGameData.MatchGameStatus.BrforeGame;
        this.levelCategory = s.levelCategory || b.GameLevelType.Easy;
        this.endGamePropCount = 0;
        this.afterEndGameCash = 0;
        this.haveShowEndGamePage = false;
        this.ad_flag = i;
        this.full_ad_flag = r;
        this.force_video = false;
        this.duringGuide = true;
        this.skipEndGameReplacement = false;
        this.levelCoinCount = 0;
        this.startReplaceStep = false;
        this.curFlyBoxCash = 0;
        this.totaleFlyBoxCash = 0;
        // this.setPropInfo(o);
        if (this.levelCategory == b.GameLevelType.GoldCoin) this.target_info = [{
            squareType: this.getSquareNumberType(b.SquareType.ObstacleItem),
            itemType: ObstacleAllType.GoldCoin,
            tootalCount: 0,
            clearCount: 0
        }]; else {
            this.target_info = this.turnTargetInfo(s.targetMatchData);
            d.log("this.target_info ", this.target_info);
        }
        this.initLevelCash();
        this._gameInfo = {
            level: this.gameLevel,
            totalStep: this.total_step,
            mapArr: s.mapArr,
            middleSquareData: s.middleSquareData,
            bottomSquareData: s.bottomSquareData,
            topSquareData: s.topSquareData,
            fixedDropData: s.fixedDropData,
            probabilityDropData: s.probabilityDropData,
            targetMatchData: this.target_info,
            levelType: this.levelCategory,
            guideIndex: this.guideIndex
        };

        window['gamelevel'] = (l) => {
            debugerGamelevel = l;
        }
    };

    public setLocalGameData(e) {
        this.gameLevel = Number(e.level);
        this.total_step = e.totalStep;
        this.left_step = this.total_step;
        this.video_step = 0;
        this.finish_propCount = 0;
        this.startGuideType = 0;
        this.guideIndex = e.guideIndex || 0;
        this.gameStatus = MatchGameData.MatchGameStatus.BrforeGame;
        this.levelCategory = e.levelCategory;
        this.endGamePropCount = 0;
        this.afterEndGameCash = 0;
        this.haveShowEndGamePage = false;
        this.levelCoinCount = 0;
        this.setPropInfo({
            2: 99,
            3: 99,
            4: 99
        });
        this.levelCategory == b.GameLevelType.GoldCoin ? this.target_info = [{
            squareType: this.getSquareNumberType(b.SquareType.ObstacleItem),
            itemType: ObstacleAllType.GoldCoin,
            tootalCount: 0,
            clearCount: 0
        }] : this.target_info = this.turnTargetInfo(e.targetMatchData);
        this.initLevelCash();
        this._gameInfo = {
            level: this.gameLevel,
            totalStep: this.total_step,
            mapArr: e.mapArr,
            middleSquareData: e.middleSquareData,
            bottomSquareData: e.bottomSquareData,
            topSquareData: e.topSquareData,
            fixedDropData: e.fixedDropData,
            probabilityDropData: e.probabilityDropData,
            targetMatchData: this.target_info,
            levelType: this.levelCategory,
            guideIndex: this.guideIndex
        };
    };
    public initTargetData() {
        d.log("初始化目标", this.target_info);
        this.updateTargetCount();
        v.instance.initTarget();
    };
    public turnTargetInfo(e) {
        for (var t = [], a = 0; a < e.length; a++) {
            var o = this.getSquareStrType(e[a].squareType), i = e[a].itemType;
            o == b.SquareType.ObstacleItem && i == ObstacleAllType.Pearl && (i = ObstacleAllType.Oyster);
            t.push({
                squareType: e[a].squareType,
                itemType: i,
                tootalCount: e[a].tootalCount,
                clearCount: 0
            });
        }
        return t;
    };
    public updateTargetCount() {
        for (var e = 0; e < this.target_info.length; e++) this.target_info[e].tootalCount = this.getTargetShowCount(this.target_info[e]);
    };
    public getFinalCoin(e) {

        var t = 0;
        if (this.levelCategory == b.GameLevelType.GoldCoin) {
            t = this.total_step + this.video_step + this.levelCoinCount;
        } else if (e) {
            t = this.total_step + this.video_step + this.levelCoinCount + this.endGamePropCount;//this.afterEndGameCash;
        } else {
            t = this.total_step + this.video_step + this.levelCoinCount + this.endGamePropCount;
        }

        t += this.getFlyBoxCash();
        console.log("getFinalCoin", this.getFlyBoxCash(), t, this.total_step, this.video_step, this.endGamePropCount, this.afterEndGameCash, this.levelCoinCount);
        return t;
    };
    public updateTarget() {
        this.updateTargetCount();
        this.updateTargetShow();
    };
    public updateTargetShow() {
        v.instance.updateTarget();
    };
    public getTargetIsFinish(e) {
        var t = this.getSquareStrType(e.squareType), a = e.itemType;
        return t == b.SquareType.ObstacleItem ? !(e.clearCount <= 0) && (a == ObstacleAllType.GoldCoin ? this.left_step <= 0 : this.getTargetShowCount(e) <= 0) : e.tootalCount <= 0;
    };
    public getTargetShowCount(e) {
        var t = this.getSquareStrType(e.squareType), a = e.itemType;
        return t == b.SquareType.ObstacleItem ? S.getObstacleTargetCountByType(a, e) : e.tootalCount;
    };
    public getAllTarget(e) {
        if (this.isFinishTarget()) return [];
        for (var t = [], a = 0; a < this.target_info.length; a++) if (this.target_info[a].isFinish) d.log("this.target_info[i]---isFinish", this.target_info[a]); else {
            var o = this.target_info[a], i = this.getOneTarget(o);
            t = t.concat(i);
        }
        var r = S.getObstacleTargetByType(ObstacleAllType.curtain);
        r.length && (t = t.concat(r));
        var n = S.getObstacleTargetByType(ObstacleAllType.MagicHat);
        n.length && (t = t.concat(n));
        var l = S.getObstacleTargetByType(ObstacleAllType.DrillFill);
        l.length && (t = t.concat(l));
        if (!e) return t;
        var s = [];
        t.forEach((e) => {
            M.isHaveObstacleInHigherLayout(e) || s.push(e);
        });
        return s;
    };
    public getOneTarget(e) {
        var t = this.getSquareStrType(e.squareType), a = e.itemType;
        return t == b.SquareType.ObstacleItem ? S.getObstacleTargetByType(a) : t == b.SquareType.MatchItem ? P.getMatchItemsByType(a) : void 0;
    };
    public getRocketRowColCount(e, t, a, o) {
        var i = 0;
        if (a) for (var r = 0; r < b.MAX_COL; r++) o[e] && o[e][r] && (i += o[e][r]); else for (var n = 0; n < b.MAX_ROW; n++) o[n] && o[n][t] && (i += o[n][t]);
        return i;
    };
    public getGridCount(e, t, a, o?) {
        void 0 === o && (o = 2);
        for (var i = 0, r = e - o; r <= e + o; r++) for (var n = t - o; n <= t + o; n++) a[r] && a[r][n] && (i += a[r][n]);
        return i;
    };
    public delatyUpdateOnsTargetCount(e, t, a, o?) {
        void 0 === o && (o = -1);
        this.scheduleOnce(this.updateOneTargetCount.bind(this, t, a, o), e);
    };
    public resetUpdateTargetCount() {
        this.unscheduleAllCallbacks();
    };
    public updateOneTargetCount(e, t, a?) {
        void 0 === a && (a = -1);
        d.log("updateOneTargetCount", e, t, a);
        for (var o = this.getSquareNumberType(e), i = 0; i < this.target_info.length; i++) if (this.target_info[i].squareType == o && this.target_info[i].itemType == t) if (this.target_info[i].squareType == this.getSquareNumberType(b.SquareType.ObstacleItem) && this.target_info[i].itemType == ObstacleAllType.GoldCoin) {
            this.target_info[i].tootalCount += 1;
            this.target_info[i].clearCount += 1;
            this.levelCoinCount += 1;
            this.addRedBack();
        } else {
            if (a >= 0) {
                this.target_info[i].tootalCount = a;
                d.log("更新tootalCount", a);
            } else this.target_info[i].tootalCount <= 0 ? this.target_info[i].tootalCount = 0 : this.target_info[i].tootalCount -= 1;
            this.target_info[i].clearCount += 1;
        }
        this.updateTargetShow();
        this.allTargetisFinish() && this.checkTargetIsFinish();
    };
    public getTargetIndexByType(e, t) {
        for (var a = this.getSquareNumberType(e), o = 0; o < this.target_info.length; o++) {
            var i = this.target_info[o], r = i.squareType, n = i.itemType;
            if (r == a && n == t) return o;
        }
        return -1;
    };
    public allTargetisFinish() {
        for (var e = 0; e < this.target_info.length; e++) if (this.target_info[e].tootalCount > 0) return false;
        return true;
    };
    public isTargetType(e, t) {
        for (var a = this.getSquareNumberType(e), o = 0; o < this.target_info.length; o++) if (this.target_info[o].squareType == a && this.target_info[o].itemType == t && this.target_info[o].tootalCount > 0) return {
            index: o
        };
        return null;
    };
    public checkTargetIsFinish() {
        d.log("checkTargetIsFinish----");
        if (this.backend_level_flag) {
            // h.getInstance().isOnlineRelease() || y.showForceToast("兜底关卡");
            d.error("兜底关卡");
            d.log("checkTargetIsFinish----消除完成------检查目标节点-----兜底关卡");
        }
        if (!this.isFinishTarget()) {
            d.log("checkTargetIsFinish----消除完成------检查目标节点-----isFinishTarget");
            return false;
        }
        if (this.gameStatus == MatchGameData.MatchGameStatus.EndGame || this.gameStatus == MatchGameData.MatchGameStatus.FinishGame) {
            d.log("checkTargetIsFinish----消除完成------游戏状态-----this.gameStatus", this.gameStatus);
            return true;
        }
        this.gameStatus = MatchGameData.MatchGameStatus.EndGame;
        v.instance.blockEliminate(true);
        u.trigger(p.ON_TARGET_FINISH);
        M.onTargetFinish();
        d.log("checkTargetIsFinish----消除完成------游戏状态-----end");
        return true;
    };
    public setEndGamePropCount(e) {
        this.endGamePropCount = e;
        d.log("剩余障碍物总数量---", this.endGamePropCount);
    };
    public isFinishTarget() {
        if (this.levelCategory == b.GameLevelType.GoldCoin) {
            this.left_step <= 0 && u.trigger(p.ONE_TARGET_FINISH, {
                index: 0
            });
            return this.left_step <= 0;
        }
        for (var e = true, t = 0; t < this.target_info.length; t++) if (this.getTargetIsFinish(this.target_info[t])) {
            if (!this.target_info[t].isFinish) {
                if (!this.isTargetHaveRealFinish(this.target_info[t])) {
                    e = false;
                    continue;
                }
                this.target_info[t].isFinish = true;
                T.playOneTargetFinishAudio();
                u.trigger(p.ONE_TARGET_FINISH, {
                    index: t
                });
            }
        } else e = false;
        return e;
    };
    public isTargetHaveRealFinish(e) {
        return this.getSquareStrType(e.squareType) !== b.SquareType.ObstacleItem || !S.getObstacleCanCreate(e.itemType);
    };
    public stepOne() {
        d.log("消除走一步");
        this.left_step -= 1;
        this.addLevelCash(1);
        if (this.left_step <= 0) {
            this.left_step = 0;
            v.instance.blockEliminate(true);
        }
        v.instance.updateStep();
    };
    public endGameStepOne() {
        d.log("游戏结束消除一步");
        this.left_step -= 1;
        if (this.left_step <= 0) {
            this.left_step = 0;
            v.instance.blockEliminate(true);
        }
        v.instance.updateStep();
    };
    public addStep(e?) {
        void 0 === e && (e = 10);
        "s0" == s.ab_add_step_flag ? e = 10 : "s1" == s.ab_add_step_flag ? e = 15 : "s2" == s.ab_add_step_flag && (e = 20);
        this.video_step += e;
        this.left_step += e;
        u.trigger(p.ADD_STEP);
        M.onAddStep();
    };
    public setSubmitData(e) {
        try {
            var t = e.props, a = e.force_video;
        this.setPropInfo(t);
        this.force_video = a;
        } catch (error) {
            
        }
    };
    public setPropInfo(e) {
        this.propInfo = [{
            skillType: SkillType.Hammer,
            skillCount: e[2]
        }, {
            skillType: SkillType.Arrow,
            skillCount: e[3]
        }, {
            skillType: SkillType.Gun,
            skillCount: e[4]
        }];
        u.trigger(p.UP_SKILL);
    };

    public getPropByType(type: SkillType): PropInfo | undefined {
        return this.propInfo.find(prop => prop.skillType === type);
    }

    public addProp(e, t) {
        this.propInfo.forEach(function (a) {
            if (a.skillType == e) {
                a.skillCount += t;
                return a;
            }
        });
        return null;
    };
    get obstacle_count_info(): any {
        return this._obstacle_count_info;
    }

    set obstacle_count_info(e: any) {
        this._obstacle_count_info = e;
    }
    public initTargetMatchType() {
        this.obstacle_count_info = [];
    };
    public resetTargetMatchType() {
        this.obstacle_count_info.forEach((e) => {
            e.tootalCount = 0;
        });
    };
    public getObstacleTypeByTarget(e) {
        switch (e) {
            case b.TargetObstacleType.WoodenBox:
                ObstacleAllType.WoodenBox;
                break;

            case b.TargetObstacleType.ColorBox:
                ObstacleAllType.ColorBox;
                break;

            case b.TargetObstacleType.Grass:
                ObstacleAllType.Grass;
                break;

            case b.TargetObstacleType.GrassLand:
                ObstacleAllType.GrassLand;
                break;

            case b.TargetObstacleType.Egg:
                ObstacleAllType.Egg;
                break;

            case b.TargetObstacleType.ColorBottle:
                ObstacleAllType.ColorBottle;
                break;

            case b.TargetObstacleType.Vase:
                ObstacleAllType.Vase;
                break;

            case b.TargetObstacleType.Honey:
                ObstacleAllType.Honey;
                break;

            case b.TargetObstacleType.Icicle:
                ObstacleAllType.Icicle;
                break;

            case b.TargetObstacleType.Pearl:
            case b.TargetObstacleType.Oyster:
                ObstacleAllType.Oyster;
                break;

            case b.TargetObstacleType.Flowerpot:
                ObstacleAllType.Flowerpot;
                break;

            case b.TargetObstacleType.Stone:
                ObstacleAllType.Stone;
                break;

            case b.TargetObstacleType.SafeBox:
                ObstacleAllType.SafeBox;
                break;

            case b.TargetObstacleType.PorcelainPig:
                ObstacleAllType.PorcelainPig;
                break;

            case b.TargetObstacleType.CupboardPlate:
                ObstacleAllType.cupboard;
                break;

            case b.TargetObstacleType.MagicHat:
                ObstacleAllType.MagicHat;
                break;

            case b.TargetObstacleType.Mail:
                ObstacleAllType.MailBox;
                break;

            case b.TargetObstacleType.Bird:
                ObstacleAllType.Bird;
                break;

            case b.TargetObstacleType.GoldCoin:
                ObstacleAllType.GoldCoin;
                break;

            case b.TargetObstacleType.PurpleFlower:
                ObstacleAllType.Flowerpot;
                break;

            case b.TargetObstacleType.Candlebox:
                ObstacleAllType.Candlebox;

            case b.TargetObstacleType.BirdNest:
                ObstacleAllType.BirdNest;
                break;

            case b.TargetObstacleType.CupHolder:
                ObstacleAllType.CupHolder;
                break;

            case b.TargetObstacleType.Rock:
                ObstacleAllType.Rock;
                break;

            case b.TargetObstacleType.DrillFill:
                ObstacleAllType.DrillFill;
        }
    };
    public getTargetObstacleArrByObstacle(e, t?) {
        void 0 === t && (t = true);
        var a = [];
        switch (e) {
            case ObstacleAllType.WoodenBox:
                a.push(b.TargetObstacleType.WoodenBox);
                break;

            case ObstacleAllType.ColorBox:
                a.push(b.TargetObstacleType.ColorBox);
                break;

            case ObstacleAllType.Grass:
                a.push(b.TargetObstacleType.Grass);
                break;

            case ObstacleAllType.GrassLand:
                a.push(b.TargetObstacleType.GrassLand);
                a.push(b.TargetObstacleType.Grass);
                break;

            case ObstacleAllType.Egg:
                a.push(b.TargetObstacleType.Egg);
                break;

            case ObstacleAllType.ColorBottle:
                a.push(b.TargetObstacleType.ColorBottle);
                break;

            case ObstacleAllType.Vase:
                a.push(b.TargetObstacleType.Vase);
                break;

            case ObstacleAllType.Honey:
                a.push(b.TargetObstacleType.Honey);
                break;

            case ObstacleAllType.Icicle:
                a.push(b.TargetObstacleType.Icicle);
                break;

            case ObstacleAllType.curtain:
                break;

            case ObstacleAllType.Oyster:
                if (t) {
                    a.push(b.TargetObstacleType.Oyster);
                    a.push(b.TargetObstacleType.Pearl);
                } else a.push(b.TargetObstacleType.Oyster);
                break;

            case ObstacleAllType.Flowerpot:
                if (t) {
                    a.push(b.TargetObstacleType.Flowerpot);
                    a.push(b.TargetObstacleType.PurpleFlower);
                } else a.push(b.TargetObstacleType.Flowerpot);
                break;

            case ObstacleAllType.Stone:
                a.push(b.TargetObstacleType.Stone);
                break;

            case ObstacleAllType.SafeBox:
                a.push(b.TargetObstacleType.SafeBox);
                break;

            case ObstacleAllType.PorcelainPig:
                a.push(b.TargetObstacleType.PorcelainPig);
                break;

            case ObstacleAllType.cupboard:
                a.push(b.TargetObstacleType.CupboardPlate);
                break;

            case ObstacleAllType.MagicHat:
                a.push(b.TargetObstacleType.MagicHat);
                break;

            case ObstacleAllType.MailBox:
                a.push(b.TargetObstacleType.Mail);
                break;

            case ObstacleAllType.Bird:
                a.push(b.TargetObstacleType.Bird);
                break;

            case ObstacleAllType.GoldCoin:
                a.push(b.TargetObstacleType.GoldCoin);
                break;

            case ObstacleAllType.Candlebox:
                a.push(b.TargetObstacleType.Candlebox);
                break;

            case ObstacleAllType.BirdNest:
                a.push(b.TargetObstacleType.Bird);
                a.push(b.TargetObstacleType.BirdNest);
                break;

            case ObstacleAllType.CupHolder:
                a.push(b.TargetObstacleType.CupHolder);
                break;

            case ObstacleAllType.Rock:
                a.push(b.TargetObstacleType.Rock);
                break;

            case ObstacleAllType.DrillFill:
        }
        return a;
    };
    public getTargetImgPath(e) {
        var t = "imgs/game/obstacle/", a = e.squareType, o = e.itemType;
        if (1 == Number(a)) t = "imgs/game/matchItem/Items-MatchItem-" + o; else if (3 == Number(a)) switch (o) {
            case ObstacleAllType.WoodenBox:
                t += ObstacleTargetName.WoodenBox;
                break;

            case ObstacleAllType.ColorBox:
                t += ObstacleTargetName.ColorBox;
                break;

            case ObstacleAllType.Grass:
                t += ObstacleTargetName.Grass;
                break;

            case ObstacleAllType.GrassLand:
                t += ObstacleTargetName.GrassLand;
                break;

            case ObstacleAllType.Egg:
                t += ObstacleTargetName.Egg;
                break;

            case ObstacleAllType.ColorBottle:
                t += ObstacleTargetName.ColorBottle;
                break;

            case ObstacleAllType.Vase:
                t += ObstacleTargetName.Vase;
                break;

            case ObstacleAllType.Honey:
                t += ObstacleTargetName.Honey;
                break;

            case ObstacleAllType.Icicle:
                t += ObstacleTargetName.Icicle;
                break;

            case ObstacleAllType.curtain:
                t += ObstacleTargetName.curtain;
                break;

            case ObstacleAllType.Pearl:
            case ObstacleAllType.Oyster:
                t += ObstacleTargetName.Pearl;
                break;

            case ObstacleAllType.Flowerpot:
                t += ObstacleTargetName.Flowerpot;
                break;

            case ObstacleAllType.Stone:
                t += ObstacleTargetName.Stone;
                break;

            case ObstacleAllType.SafeBox:
                t += ObstacleTargetName.SafeBox;
                break;

            case ObstacleAllType.PorcelainPig:
                t += ObstacleTargetName.PorcelainPig;
                break;

            case ObstacleAllType.cupboard:
                t += ObstacleTargetName.cupboardPlate;
                break;

            case ObstacleAllType.MagicHat:
                t += ObstacleTargetName.Gem;
                break;

            case ObstacleAllType.MailBox:
                t += ObstacleTargetName.Mail;
                break;

            case ObstacleAllType.Bird:
                t += ObstacleTargetName.Bird;
                break;

            case ObstacleAllType.GoldCoin:
                t += ObstacleTargetName.GoldCoin;
                break;

            case ObstacleAllType.PurpleFlower:
                t += ObstacleTargetName.PurpleFlower;
                break;

            case ObstacleAllType.Candlebox:
                t += ObstacleTargetName.Candlebox;
                break;

            case ObstacleAllType.BirdNest:
                t += ObstacleTargetName.BirdNest;
                break;

            case ObstacleAllType.CupHolder:
                t += ObstacleTargetName.CupHolder;
                break;

            case ObstacleAllType.Rock:
                t += ObstacleTargetName.Rock;
                break;

            case ObstacleAllType.DrillFill:
                t += ObstacleTargetName.DrillFill;
        }
        return t;
    };
    get middle_square_grid(): any {
        return this._middle_square_grid;
    }

    set middle_square_grid(e: any) {
        this._middle_square_grid = e;
    }

    get bottom_square_grid(): any {
        return this._bottom_square_grid;
    }

    set bottom_square_grid(e: any) {
        this._bottom_square_grid = e;
    }

    get top_square_grid(): any {
        return this._top_square_grid;
    }

    set top_square_grid(e: any) {
        this._top_square_grid = e;
    }
    public getSquareNumberType(e) {
        var t;
        e == b.SquareType.MatchItem ? t = 1 : e == b.SquareType.ObstacleItem ? t = 3 : e == b.SquareType.PropItem ? t = 2 : e == b.SquareType.Null ? t = -1 : e == b.SquareType.EMPTY && (t = -2);
        return t;
    };
    public getSquareStrType(e) {
        var t;
        1 == e ? t = b.SquareType.MatchItem : 3 == e ? t = b.SquareType.ObstacleItem : 2 == e ? t = b.SquareType.PropItem : -1 == e ? t = b.SquareType.Null : -2 == e && (t = b.SquareType.EMPTY);
        return t;
    };
    public getSkillName(e) {
        if (e == SkillType.Null) return null;
        var t = "";
        switch (e) {
            case SkillType.Arrow:
                t = "arrow";
                break;

            case SkillType.Gun:
                t = "gun";
                break;

            case SkillType.Hammer:
                t = "hammer";
                break;

            case SkillType.Shiff:
                t = "shiff";
        }
        return t;
    };
    public setEnableMultiTouch(e) {
        cc.macro.ENABLE_MULTI_TOUCH = 1 == e;
    };
    public isEnableDebug() {
        // if (!cc.sys.isNative) {
        //     return true;
        // }
        return false//true;
    };
    public getNextCityTipString() {
        var e = "<color=#973836>加油，还有</c><color=#E40500> " + c.getTravelLocation().need + " </color><color=#973836>关到下个城市！</c>";
        20 == this.gameLevel && (e = "<color=#973836>用尽步数收集尽可能多的</c><color=#E40500>红包</color><color=#973836>！</c>");
        return e;
    };
    public loadCityData() {
        var e = this;
        m.loadResourceAsset("absurface/CityData").then(function (t) {
            if (t) {
                var a = t['json'];
                a && (e.cityConfig = a);
            }
        }).catch((e) => {
            console.log("err====", e);
        });
    };
    public isOppoChannel() {
        return "oppo" == f.channel_name;
    };
    // var a;
    // return a = r([A], t);
}

export default MatchGameData.getInstance();
